using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication11.Models.Mapping
{
    public class ImageMap : EntityTypeConfiguration<Image>
    {
        public ImageMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.ImgPath)
                .HasMaxLength(150);

            // Table & Column Mappings
            this.ToTable("Image");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.ImgPath).HasColumnName("ImgPath");
            this.Property(t => t.PatientBasicId).HasColumnName("PatientBasicId");
            this.Property(t => t.CreateDate).HasColumnName("CreateDate");
            this.Property(t => t.ImgCategoryId).HasColumnName("ImgCategoryId");

            // Relationships
            this.HasOptional(t => t.ImgCategory)
                .WithMany(t => t.Images)
                .HasForeignKey(d => d.ImgCategoryId);
            this.HasOptional(t => t.PatientBasic)
                .WithMany(t => t.Images)
                .HasForeignKey(d => d.PatientBasicId);

        }
    }
}
